// pages/restaurant/shop/shopComponent/shopComponent.js
import {list} from '../../api/recommend'
import util from '../../utils/util'
const app=getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    billFareAffiliated:{
      type:Array,
    }
  },
lifetimes:{
  attached(){
    // this.loadSHop()
  }
},
  /**
   * 组件的初始数据
   */
  data: {
      shops:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    toDetail(e){
      wx.navigateTo({
        url: '/pages/shop/shopDetail/index?shopId='+e.currentTarget.dataset.id+'&mchId='+e.currentTarget.dataset.mchid
      })

    },
    loadSHop(){
      list({
        type:1,
        lng:app.globalData.lng,
        lat:app.globalData.lat
      }).then(res=>{
        res.data.data.forEach(item=>{
          item.distance=util.rateConverter(item.distance)
            item.shopVo.logo=util.thumbnail(item.shopVo.logo,157,157)
        })
        this.data.shops=res.data.data
        this.setData({
          shops:this.data.shops
        })
      })
    },
  }
})
